package spring01.processor;


import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

/**
 * 后置处理器（Bean实例化前后进行处理）
 */
public class MyBeanPostProcessor implements BeanPostProcessor {

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("MyBeanPostProcessor.postProcessBeforeInitialization");
        return null;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
    /*	if(beanName.equals("userService")){
			UserService userService = (UserService) bean;
			userService.setUserDao(new UserDao());
		}*/
        System.out.println("MyBeanPostProcessor.postProcessAfterInitialization");
        return null;
    }
}
